import React, { useEffect,useState } from 'react';
import { PageContainer } from "@ant-design/pro-layout";
import {getBasicInfo} from '@/pages/service';
import { Card } from 'antd';
import arouter from '@/utils/apulis-router';

const DashBoard:React.FC = () => {
  const [presetModelNum,setPresetModelNum] = useState(0)
  const [userModelNum,setUserModelNum] = useState(0)

  useEffect(() => {
    getBasicInfo().then(res=>{
      console.log(res)
      if(res.code===0){
        setPresetModelNum(res.data.preset)
        setUserModelNum(res.data.published)
      }
    })

  }, []);
  return (
    <PageContainer>
      <div style={{display:"flex"}}>
        <Card title="预置模型"  style={{ width: 300 ,marginRight:"20px", cursor:'pointer'}}
              onClick={e=>{arouter({ name: 'modelIndex', query: { source: 'preset' } });}}>
        <p>{presetModelNum}</p>
        </Card>
        <Card title="用户模型"  style={{ width: 300, cursor:'pointer'}}
              onClick={e=>{arouter({ name: 'modelIndex', query: { source: 'publish' } });}}>
          <p>{userModelNum}</p>
        </Card>
      </div>
    </PageContainer>
  );
}

export default DashBoard;
